package com.ymttest.business.service.productdata.service;

import java.io.File;
import java.util.Arrays;
import java.util.List;

import com.ymatou.iapi.productmanager.service.UpdateProductSensitiveWordCall;
import com.ymttest.utils.FileUtil;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.compare.AssertHelper;
import com.ymttest.utils.compare.LogPathConf;
import com.ymttest.utils.compare.LoggerHelper;
import com.ymttest.utils.compare.LoggerInterface;

public class UpdateProductSensitiveWord {
	public static void main(String args[]){
		LogPathConf logPathConf = new LogPathConf(false);
		LoggerInterface logger = new LoggerHelper(logPathConf);
		AssertHelper.setLoggerInterface(logger);
		
		
		int propertyTypes = 2;
		List<String> senWords = Arrays.asList("消炎","抗菌");
		
		
		String userIdAndName = System.getProperty("user.dir") + File.separator + "resource" + File.separator
				+"CompareData"+File.separator+"userId_productId.txt"; 
		
		List<String> userAndproductIds = FileUtil.readFileAsLine(userIdAndName);
		
		
		for(int i=0;i<userAndproductIds.size();i++){
			String[] strs = userAndproductIds.get(i).split(",");
			String productId = strs[1];
			int sellerId =  Integer.parseInt(strs[0]);
			
			System.out.println("sellerId:"+sellerId+",productId:"+productId);
			
			for (int j=0;j<senWords.size();j++){
				Boolean ret = new UpdateProductSensitiveWordCall().call(productId, sellerId, propertyTypes, senWords.get(j));
				if (ret){
					logger.verifyEquals(true, true, "productId:"+productId+", update success");
				}else{
					logger.verifyEquals(true, true, "productId:"+productId+", update faied");
				}
				
			}
				
		} 
		YMTDateUtil.waitTime(0.05);
		
	}
}
